package com.itheima.app.interceptor;

import com.itheima.domain.db.User;

// 当前线程存储user对象的工具类
public class UserHolder {

    private static final ThreadLocal<User> tl = new ThreadLocal();

    // 设置user到线程
    public static void set(User user) {
        tl.set(user);
    }

    // 从线程中获取user
    public static User get() {
        return tl.get();
    }

    // 从线程中移除user
    public static void remove(){
        tl.remove();
    }
}
